cc.Class({
    extends: cc.Component,

    properties: {
    },


    onLoad () {
        this.speed = 50;
        this.viewHeight = cc.view.getVisibleSize().height;
        let bulletBag = this.node.getComponent(cc.BoxCollider).tag;
        if (bulletBag==11) {
            this.bulletPool = "bulletPool";//绿色子弹
        }
        else if (bulletBag==12) {
            this.bulletPool = "bullet1Pool";//蓝色子弹
        }
    },
    onCollisionEnter: function(other, self) {
        let e = this;
        game.pools.putNode(e.bulletPool,self.node);//回收子弹
        if(other.tag==1){  //敌人1
            var enemy=other.node.getComponent('enemy');
        }else if(other.tag==2){  //敌人2
            var enemy=other.node.getComponent('enemy2');
        }
        else if(other.tag==3){  //敌人2
            var enemy=other.node.getComponent('enemy3');
        }
        else if (other.tag==4) {
            let boss = other.getComponent("enemyBoss");
            boss.hit()
            
        }
        if(enemy && enemy.isDie==false){
            enemy.hit(1);
            game.checkNUmber();
        }
    },
   

    update (dt) {
        
        if(game.isStart){
            this.node.y+=15;
            if(this.node.y>this.viewHeight)
                game.pools.putNode(this.bulletPool,this.node);
        }
        
    },
});
